package collection.MyTree;


import java.util.*;

public class Test {
    public static void main(String[] args) {
        BinaryTree tree = new BinaryTree();
        BinaryTree.TreeNode root = tree.createTree();
        BinaryTree.TreeNode p = root.left.left;
        BinaryTree.TreeNode q = root.right;
        Collection<Integer> list = new LinkedList<>();
        



        System.out.print("前序遍历：");//ABCDEGF
        tree.preOrder(root);
        System.out.println();

        System.out.print("中序遍历：");//CBEGDFA
        tree.inOrder(root);
        System.out.println();

        System.out.print("后序遍历：");//
        tree.postOrder(root);
        System.out.println();

        System.out.println("节点总数：" + tree.nodeSize(root));
        System.out.println("叶子的节点数量：" + tree.getLeafSize(root));
        System.out.println("第一层的节点个数：" + tree.getKLevelNodeCount(root,1));
        System.out.println("第二层的节点个数：" + tree.getKLevelNodeCount(root,2));
        System.out.println("第三层的节点个数：" + tree.getKLevelNodeCount(root,3));
        System.out.println("第四层的节点个数：" + tree.getKLevelNodeCount(root,4));
        System.out.println("树的高度： " + tree.getHeight(root));
        System.out.println("层序遍历：" + tree.levelOrder(root));
        System.out.println("公共祖先：" + tree.lowestCommonAncestor(root,p,q).val);
        if (tree.lowestCommonAncestorStack(root,p,q)!=null){
            System.out.println("公共祖先：" + tree.lowestCommonAncestorStack(root,p,q).val);
        }


    }
}
